package com.popo.test;

public class MapHashCode {
	private static int h = 0;
	
	static int size=23;
	public static void main(String[] args) {
		for (int i = 0; i < 23; i++) {
			Object o = new Object();
			int h = o.hashCode();
			int sh = secondaryHash(h);
			int ssh = indexFor(sh, size);
			
			System.out.println(" h="+h+",sh="+sh+",ssh="+ssh);
			

		}
	}

	private static int secondaryHash(int h) {
		// Doug Lea's supplemental hash function
		h ^= (h >>> 20) ^ (h >>> 12);
		h = h ^ (h >>> 7) ^ (h >>> 4);
		System.out.print(h);
		return h;
	}

	static int hash(int h) {
		// This function ensures that hashCodes that differ only by
		// constant multiples at each bit position have a bounded
		// number of collisions (approximately 8 at default load factor).
		h ^= (h >>> 20) ^ (h >>> 12);
		return h ^ (h >>> 7) ^ (h >>> 4);
	}

	/**
	 * Returns index for hash code h.
	 */
	static int indexFor(int h, int length) {
		return h & (length - 1);
	}
	
}

class Aa{
	String a;
	public Aa(String a){
		this.a=a;
	}
	
	@Override
	public int hashCode() {
		// TODO Auto-generated method stub
		int hash=super.hashCode();
	
		return hash;
	}
	
}
